<?php
class AdminController extends Zend_Controller_Action
{

    public function init()
    {
        $this->session = new Zend_Session_Namespace("Admin");
    }

    // Admin login page
    public function loginAction()
    {
        $username = $this->_getParam("username");
        $pwd = $this->_getParam("pwd");


        if (empty($username) || empty($pwd)) {

            $this->render();
        } else {
            $studentsModel = new Application_Model_Students();
            if ($studentsModel->checkLogin($username, $pwd)) {
                $this->session->username = $username;
                $this->_redirect("/admin/dashboard");
            } else {
                $this->view->error = "Login Failed";
                $this->render();
            }
        }
    }

    

}